<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title></title>
    {include file='header'}  
</head>

<body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" id="login_pwd" name="login_pwd" value="" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                </div>
            </div>    
            <div class="layui-form-item">
                <label class="layui-form-label label-required">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" id="login_pwd2" name="login_pwd2" value="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div> 
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-filter="save" lay-submit="">保存</button>
                </div>
            </div>
        </form>
    </div>       
<script>
layui.use('form', function(){
  var form = layui.form;  
  //监听提交
  form.on('submit(save)', function(data){
    console.log(data.field)
    
    $.ajax({
        type: "POST",
        url: "{:url('password')}",
        data: data.field,
        datatype: "json",
        success: function (res, textStatus) {        
            console.log(res)                
            if (res.code == 1) {
                layer.msg('修改成功', { icon: 1,time:1000 },function(){
                    location.href="{:url('index')}"
                    parent.location.reload();
                });
            }
            else {
                layer.msg(res.msg, { icon: 5 });//0感叹号  1打勾  2打叉  3问号  4锁头  5难过  6笑脸
                return false;
            }
        },
        error: function (e) {
            layer.alert('系统出现错误,请检查系统！', { icon: 2 });
            return false;
        }
    });
    return false;
  });
});
</script>
</body>
</html>